// ==UserScript==
// @name         知乎取消弹窗脚本
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  自动取消知乎登录弹窗
// @author       Mingyueyixi
// @match        https://*.zhihu.com/*
// @grant        none
// ==/UserScript==

(function () {
    const timeId = setInterval(hide, 100);

    function hide() {
        let closeButton = document.querySelector("div.Modal.Modal--default.signFlowModal > button");
        if (!closeButton) {
            return
        }
        try {
            let modal = document.querySelector(".Modal-enter-done");
            modal? modal.style.display = "none":undefined

            closeButton && closeButton.click()
            console.log(">>>已自动隐藏知乎登录窗")
        } catch (error) {
            console.error(error)
        } finally {
            window.clearInterval(timeId)
        }
    }
})();
